package test;


import java.util.Scanner;

public class 统计一个数字在升序数组中出现的次数 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int n = scanner.nextInt();

        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }

        System.out.println(getNumberOfK(nums, Integer.parseInt(s)));
    }

    private static int getNumberOfK(int[] nums, int k) {
        // 二分查找k的最左边位置和最右边位置
        int left = binarySearch(nums, k - 0.5);
        int right = binarySearch(nums, k + 0.5);

        // 计算k出现的次数
        return right - left;
    }

    // 二分查找
    private static int binarySearch(int[] nums, double target) {
        int left = 0, right = nums.length - 1;
        while (left <= right) {
            int mid = (left + right) / 2;
            if (nums[mid] < target) {
                left = mid + 1;
            } else if (nums[mid] > target) {
                right = mid - 1;
            }
        }
        return left;
    }
}
